package com.twu.bibilioteca;

import java.nio.file.LinkOption;
import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * User: dixithk
 * Date: 6/12/14
 * Time: 5:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class Library {

    public  ArrayList<Book> books = new ArrayList<Book>();
    

    public void addBook(Book book)
    {
          books.add(book);
    }

    public  ArrayList<Book> getBooks()
    {
        ArrayList<Book> availableBooks = new ArrayList<Book>();
        for(Book book :books)
        {
              if(!book.isCheckedOut())
              {
                  availableBooks.add(book);
              }
        }
        return availableBooks;
        
    }

    public Book GiveBookObjectFromTitle(String BookQueryTitle ) {



        for (Book book : books) {
            if ((book.getTitle()).equals(BookQueryTitle)) {

                return book;
            }

        }

        return null;

    }



    public  boolean isAvailableForCheckOut(Book book)
    {
       return book.isCheckedOut();
    }

    public  boolean isValidReturn(Book bookNeedToBeReturned) {
            
        return bookNeedToBeReturned.isCheckedOut();
    }


    public void loadBooks()
    {
        books.add(new Book("program in C" , "subbu" , 1998 , false));
        books.add(new Book("program in java" , "subbu" , 1998 , false));
        books.add(new Book("program in python" , "subbu" , 1998, false));
        books.add(new Book("program in Ruby" , "subbu" , 1998, false));
        books.add(new Book("program in scala" , "subbu" , 1998, false));
    }

}
